package com.exeample.appium;

import com.exeample.appium.utils.OperationUtils;
import io.appium.java_client.android.AndroidDriver;
import lombok.extern.slf4j.Slf4j;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
@Slf4j
public class AlipayAppium {
    //设备号
    public static String deviceName;
    public static AndroidDriver driver;
/*
    static {
        try {
            driver = OperationUtils.getPropertiesByInputStream_Four();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args){
        try{
            setLogin("18309864917","qaz621014");
        }catch (Exception e){
            System.out.println("出现异常！"+e.getMessage());
            e.printStackTrace();
        }
    }*/

    /**
     * 支付宝账户登录
     * @param accountEdit 账号
     * @param passwordEdit 密码
     */
    public static void setLogin(String accountEdit, String passwordEdit){
        log.info("setLogin ... accountEdit={},passwordEdit={}",accountEdit,passwordEdit);
        try{
            //登录
            OperationUtils.findAndClick(driver, "com.ali.user.mobile.security.ui:id/loginButton");
            OperationUtils.delay(driver, 2);
            //账号
            OperationUtils.findAndClick(driver, "com.ali.user.mobile.security.ui:id/userAccountInput");
            WebElement weOne = driver.findElement(By.id("com.ali.user.mobile.security.ui:id/userAccountInput"));
            weOne.sendKeys(accountEdit);
            //密码
            OperationUtils.findAndClick(driver, "com.ali.user.mobile.security.ui:id/userPasswordInput");
            WebElement weTwo = driver.findElement(By.id("com.ali.user.mobile.security.ui:id/userPasswordInput"));
            weTwo.sendKeys(passwordEdit);
            //登录
            OperationUtils.findAndClick(driver, "com.ali.user.mobile.security.ui:id/loginButton");



            log.info("setLogin ... successfull");
        }catch (Exception e){
            System.out.println("setLogin 出现异常！"+e.getMessage());
            e.printStackTrace();
        }
    }
}
